//
//  UILabel+Extension.swift
//  LRWeibo
//
//  Created by admin on 15/9/21.
//  Copyright © 2015年 懒人. All rights reserved.
//

import UIKit

extension UILabel{
    
    convenience init(title: String, color: UIColor, fontSize: CGFloat, layoutWidth: CGFloat = 0)
    {
        self.init()
        
        text = title
        textColor = color
        font = UIFont.systemFontOfSize(fontSize)        
        numberOfLines = 0

        // 设置宽度
        if layoutWidth > 0
        {
            // 预设最大宽度
            preferredMaxLayoutWidth = layoutWidth
            textAlignment = NSTextAlignment.Left
        }
        else
        {
            textAlignment = NSTextAlignment.Center
        }
        
        sizeToFit()
    }
    
}
